package com.xiyu.service.repository.fee.recharge;

import com.xiyu.service.model.elder.info.ElderInfoFetcher;
import com.xiyu.service.model.fee.recharge.FeeRechargeDetailFetcher;
import com.xiyu.service.vo.fee.feeRecharge.FeeRechargePageQueryDetailInput;
import com.xiyu.service.model.fee.recharge.FeeRechargeDetail;
import com.xiyu.service.model.fee.recharge.FeeRechargeDetailTable;
import org.babyfish.jimmer.spring.repository.JRepository;
import org.babyfish.jimmer.Page;
import org.springframework.util.StringUtils;

public interface FeeRechargeDetailRepository extends JRepository<FeeRechargeDetail, Long> {
    FeeRechargeDetailTable feeRechargeDetailTable = FeeRechargeDetailTable.$;

    default Page<FeeRechargeDetail> pageQueryDetail(FeeRechargePageQueryDetailInput inputVO){
        return sql().createQuery(feeRechargeDetailTable)
                .whereIf(StringUtils.hasText(inputVO.getName()), () -> feeRechargeDetailTable.elder().name().like(inputVO.getName()))
                .whereIf(inputVO.getStatus() != null, feeRechargeDetailTable.status().eq(inputVO.getStatus()))
                .orderBy(feeRechargeDetailTable.id().desc())
                .select(feeRechargeDetailTable.fetch(FeeRechargeDetailFetcher.$.allTableFields()
                        .elder(ElderInfoFetcher.$.allTableFields())))
                .fetchPage(inputVO.getPageNo() - 1, inputVO.getPageSize());
    }


}